<?php 
/**
 * PORTFOLIO 1 Leftsidebar
 * The main template file for display portfolio page.
 *
 * @package WordPress
*/
wp_enqueue_script('prettyPhoto');
$types_arr=array();
if(get_theme_option('portfolio','portfolio_enable_filter') =='true' && !is_archive() ):
    $types=get_terms('portfolio-types');
	$num=0;
		if($types) :
           foreach($types as $type):
        		$types_arr[$num]='<li><a href="#'.str_replace(' ','-',$type->name).'">'.$type->name.'</a></li>'."\n";
        		$num++;
           endforeach;
		 endif;
?>
                    <div class="seperator">
                    	<ul id="portfolio-filter">
                            <li><a href="#all" title="">All</a></li>
                            <?php echo implode(' ',$types_arr);?>
                        </ul>
                    </div>
			
<?php endif; ?>
					<div class="portfolio-item">
						 <ul id="portfolio-list">		
<?php
global $posts;
$curr_count=0;
$sum = 0;
while(have_posts()): the_post();
//Get setting
$enable_lightbox = get_theme_option('portfolio','portfolio_enable_lightbox');
$enable_filter = get_theme_option('portfolio','portfolio_enable_filter');
$image = get_meta_option('image_upload_portfolio',get_the_ID());

$video = get_meta_option('video_embed_code',get_the_ID());
$video_embed=get_meta_option('video_embed_code',get_the_ID());
$youtube_video = get_meta_option('youtube_id',get_the_ID());
$vimeo_video = get_meta_option('vimeo_id',get_the_ID());
$video_style = get_meta_option('video_style',get_the_ID());


$direct_link = get_meta_option('direct_url_portfolio',get_the_ID());

$portfolio_number_chacter =get_theme_option('portfolio','portfolio_number_chacter');
$portfolio_number_chacter =get_theme_option('portfolio','portfolio_number_chacter');
$portfolio_readmore_link =get_theme_option('portfolio','portfolio_readmore_link');

  $sum++;
  $image_thumb = '';
  if(has_post_thumbnail(get_the_ID())):
    $images_id=get_post_thumbnail_id(get_the_ID());
    $image_thumb=wp_get_attachment_image_src($images_id,'194-148');
	$type_portfolio = get_meta_option('portfolio_type',get_the_ID());
  endif;
  $types_portfolio=get_the_terms(get_the_ID(),'portfolio-types');
  $types_portfolio_arr = array();
  $num=0;
  if($types_portfolio) :
     foreach($types_portfolio as $type):
        $types_portfolio_arr[$num]=str_replace(' ','-',$type->name);
        $num++;
     endforeach;
 endif;
?>


						 
                            <li class="<?php echo implode(' ',$types_portfolio_arr);?>">
                                <div class="port-shadow">
                                  <div class="mosaic-block bar2">
                                      <div class="mosaic-overlay">
                                          <div class="details">
                                              <h2><?php the_title();?></h2>
											   <?php if($enable_lightbox=='true'): ?>
        											   <?php if($type_portfolio=='1') : $image_upload=get_meta_option('image_upload_portfolio',get_the_ID()); ?>
                                                       <div><a rel="prettyPhoto" class="zoom-icon" href="<?php echo $image_upload; ?>" title="<?php the_title(); ?>">&nbsp;</a> <a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
        											 <?php elseif($type_portfolio=='2') :
                                                       if($video_style =="embed") :
                                						?>
                        						   	    
														<div><a rel="prettyPhoto" class="video-icon"   href="#video<?php echo $sum?>" title="<?php the_title(); ?>"></a><a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
                                						<?php 
                        								elseif($video_style =="youtube") :
                        								?>
                        								
                        						  		 <div><a rel="prettyPhoto" class="video-icon"   href="http://www.youtube.com/watch?v=<?php echo $youtube_video;?>" title="<?php the_title(); ?>"></a><a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
                        								<?php
                        								elseif($video_style =="vimeo") :
                        								?>
                        								
                        						   		<div><a href="http://vimeo.com/<?php echo $vimeo_video;?>"  class="video-icon" rel="prettyPhoto" title="<?php the_title(); ?>"></a><a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
                    									<?php endif; ?>
        											  <?php elseif($type_portfolio=='3') : $image_upload=get_meta_option('image_upload_portfolio',get_the_ID());
        												$direct_url_portfolio=get_meta_option('direct_url_portfolio',get_the_ID());
                                 						?>
                 								
                         								<div><a rel="prettyPhoto[iframes]" class="link-icon" href="<?php  echo $direct_url_portfolio; ?>?iframe=true&width=100%&height=100%" title="<?php the_title(); ?>"></a><a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
                         						
                         								<?php endif; ?>
													<?php else: ?>
													
														<div><a href="<?php  echo get_permalink() ?>" class="plus-icon">&nbsp;</a></div>
													<?php endif ?>
													
                                          </div>
                                      </div>
                                      <?php if(!empty($image_thumb)) :?>
									  
        							     <div class="mosaic-backdrop"><img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_thumb[0]; ?>&amp;h=148&amp;w=194&amp;zc=1" alt="<?php the_title()?>"></div>
               						
       								  <?php endif;?>
									  
                                  </div>                    	
                        		</div>
                            </li>
                            
	
<?php endwhile; ?>
	  			  			<li style="overflow: hidden; clear: both; height: 0px; position: relative; float: none; display: block;"></li>
                        	
						</ul>
					</div> 
					<div class="clearfix"></div>
<?php tt_pagination();	?>